<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h3></h3>
<script>
    let aa = document.querySelector('h3')
    t()
    //定时器，每1秒会执行
    setInterval(t,1000)

    function t(){
        let dd = new Date()
        let hh = String(dd.getHours()).padStart(2,'0')
        let mi = String(dd.getMinutes()).padStart(2,'0')
        let ss = String(dd.getSeconds()).padStart(2,'0')
        aa.innerHTML = `${hh}:${mi}:${ss}`
        //document.write(`${hh}:${mi}:${ss}`)
    }
</script>
</body>
</html>
